package com.mylife.user.controller;

import com.mylife.pojo.Result;
import com.mylife.user.service.UserService;
import com.mylife.user.vo.params.UserAccountParams;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;

/**
 * 用户信息controller
 * @author blueCat
 * @since 2022-01-08
 */
@RestController
@RequestMapping("/mylife/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 用户账号注册
     * @param params(username,password,sex,birthday)
     * @return String
     */
    @PostMapping("/register")
    public Result registerAccount(@RequestBody UserAccountParams params){ ;
        return userService.registerAccount(params);
    }

    /**
     * 用户登录
     * @param params(username,password)
     * @return String
     */
    @PostMapping("/login")
    public Result loginAccount(@RequestBody UserAccountParams params, HttpServletResponse resp){
        return  userService.loginAccount(params,resp);
    }
}
